<?
require_once(dirname(__FILE__) . "/config.php");
require_once(dirname(__FILE__) . "/db.php");

$lsValorSelecionado = $_GET["valorPadrao"];
$lsTipo = $_GET["tipo"];
$lsParam = $_GET["param"];
$lsInsereSelecione = $_GET["pesq"];
$lsSelecionaItem = "";

switch($lsTipo)
{
	case "1":
		$lsHTMLRet .= "<script language='JavaScript'>var Ret;Ret = top.getObj('layerCidade');Ret.innerHTML = \"<select class='formSelect' name='cd_municipio' '>\" ";
		if ($lsInsereSelecione=="true")
		{
			$lsHTMLRet.=" + \"<option value='0'>Selecione</option>\" ";
		}
		$lsSql = "Select cd_municipio, dc_municipio from municipio where cd_uf = '" . $lsParam . "' Order By dc_municipio";
		$result = db_query($lsSql);
		
		while($lst=mysql_fetch_array($result))
		{
			if($lsValorSelecionado == $lst["cd_municipio"])
			{
				$lsSelecionaItem = "selected";
			}
			else
			{
				$lsSelecionaItem = "";
			}
			$lsHTMLRet .= "+ \"<option value=" . $lst["cd_municipio"] . " " . $lsSelecionaItem . ">" . $lst["dc_municipio"] . "</option>\"";
		}
		$lsHTMLRet .= "+ \"</select>\";</script>";
		break;
}
echo($lsHTMLRet);
?>